! double grille  /last modified by VL 11/29/94/
! a=int. width, b=int. height,
! c=int. frame thickn., d=int. frame width,
! e=no. of horiz. panes, f=no. of vert. panes

!******** checking for parameter errors  *******
if e<2 and f<2 then 20000
if a-e*d<-0.001 or b-f*d<-0.001 then 10000
e = max (abs(e),1) : f = max (abs(f),1)

!***********  internal variables  **************
u=(a+d)/e : v=u-d
t=(b+d)/f : w=t-d

!*****  contour for independent grid lines *****
if e>1 and f>1 then 200
100:!*** independent grid lines ("e" or "f"=1)
if e=1 then 102
101:!*** f=1
  gosub 210
  goto 2000
102:!*** e=1
  gosub 220
  goto 2000

200:
!*******  contour for grid with holes **********
gosub 210
gosub 220
gosub 230
gosub 240
if e<3 or f<3 then 1000

!******************  holes  ********************
put v,w,-1     ! end of contour

for i = 1 to e-2
  for j = 1 to f-2
     x = i*u  :  y = j*t
     put   x , y   , 15,
         x+v , y   , 15,
         x+v , y+w , 15,
           x , y+w , 15,
           x , y   , -1
  next j
next i

!***********  creating the grid  ***************
1000: !*** grid with holes
prism_ (nsp/3), c,
       get (nsp)
end
2000: !*** independent grid lines
for i=1 to z-1
  prism_ 4,c,
         get(4*3)
next i
end
!**********************************************
10000: print "to many panes"
20000:
end
!***************  subroutines  ****************

210: !******************* bottom
for i = 1 to e-1
   x = i*u
     put x-d , w,15,
         x-d , 0,15,
           x , 0,15,
           x , w ,15
        next i
z=e
return

220: !****************** right
for i = 1 to f-1
   y = i*t
     put a-v , y-d,15,
           a , y-d,15,
           a ,   y,15,
         a-v ,   y,15
       next i
z=f
return

230: !****************** top
for i = e-1 to 1 step -1
   x = i*u
      put    x , b-w,15,
             x ,   b,15,
           x-d ,   b,15,
           x-d , b-w,15
        next i
return

240: !****************** left
for i = f-1 to 1 step -1
   y = i*t
      put v ,   y,15,
          0 ,   y,15,
          0 , y-d,15,
          v , y-d,15
       next i
return